<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>删除字符使字符串变好</title>
</head>
<body>
  <script>
    function fn(s) {
      let a = s.substring(0, 2).split('')
      for (let i of s.substring(2)) {
        if (a[a.length - 1].concat(a[a.length - 2]) !== i + i) {
          a.push(i)
        }
      }
      return a.join('')
    }
    console.log(fn('leeetcode'))
  </script>
</body>
</html>